<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/vue.min.js"></script>
</head>

<body>
    <div id="app">
        <label>名：<input type="text" v-model="firstName"></label>
        <label>姓：<input type="text" v-model="lastName"></label>
        <h2>{{fullName}}</h2>
    </div>
</body>
<script>
    var VM = new Vue({
        el: '#app',
        data: {
            firstName: '',
            lastName: '',
            fullName: '',
        },
        methods: {},
        watch: {
            firstName: function(nval, oval) {
                this.fullName = nval + " " + this.lastName;
            },
            lastName: function(nval, oval) {
                this.fullName = this.firstName + " " + nval;
            }
        },
    })
</script>

</html>